# -*- coding: utf-8 -*-

import requests
from demo_common_module.utils.exception_type import *


class UserHelper(object):

    @classmethod
    def get_sso_user_info(cls, token):
        url = "https://sso.shanyingintl.com/Authorize/Trusted.aspx?Ticket={}".format(token)
        resp = requests.get(url)
        status_code = resp.status_code
        if status_code == 200:
            user_id = resp.content.decode("utf-8").replace("\r\n", "")
            if user_id:
                return user_id
        if status_code == 500:
            # TODO 后期开启该代码，删除返回代码
            # raise Exception500("获取用户信息失败")
            # return "V0375"
            return "V0377"
